package com.example.activityproject201202;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import java.io.Serializable;

public class OneActivity  extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.one_activity_layout);

        Log.i("OneActivity","对象名称："+this);
        //获取到intent对象
        Intent intent = getIntent();
        User user = (User) intent.getSerializableExtra("user_key");
    //    Log.i("OneActivity","姓名："+user.getName()+" 年龄："+user.getAge());

        Button to_one_act_bt = findViewById(R.id.to_one_act_bt);
        to_one_act_bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent1 = new Intent(OneActivity.this, OneActivity.class);
                startActivity(intent1);
            }
        });
        Button to_red_act_bt = findViewById(R.id.to_red_act_bt);
        to_red_act_bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent1 = new Intent(OneActivity.this,RedAct.class);
                startActivity(intent1);
            }
        });

    }

}
